package com.example.clientbwic.controller;

import com.example.clientbwic.entity.Bwic;
import com.example.clientbwic.entity.BwicRespose;
import com.example.clientbwic.entity.Client;
import com.example.clientbwic.service.bwic.BwicService;
import com.example.clientbwic.utils.BwicToBwicResponse;
import com.example.clientbwic.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: 86150
 * @Date: 2024/4/9
 * @Description: com.example.clientbwic.service
 */
@RestController
public class BwicController {
    @Autowired
    BwicService bwicService;
    @GetMapping("/bwic/list/{clientId}")
    public Result<List<BwicRespose>> getBwicListByClientId(@PathVariable Long clientId) {
        List<Bwic> list = bwicService.getBwicListByClientId(clientId);
        List<BwicRespose> bwicResposes = BwicToBwicResponse.convert(list);
        return Result.success(bwicResposes);
    }
    @GetMapping("/bwic/list/")
    public Result<List<Bwic>> getBwicList() {
        List<Bwic> list = bwicService.getBwicList();
        return Result.success(list);
    }

}
